package com.nc.delivery_project.shared.locator;

import com.google.web.bindery.requestfactory.shared.Locator;
import com.nc.delivery_project.server.domain.LegalPerson;
import com.nc.delivery_project.server.service.LegalPersonService;
import com.nc.delivery_project.shared.servicelocator.LegalPersonServiceLocator;

/**
 * Created by miroshnik on 1/28/2015.
 */
public class LegalPersonLocator extends Locator<LegalPerson, Integer> {
    
    @Override
    public LegalPerson create(Class<? extends LegalPerson> clazz) {
        return new LegalPerson();
    }

    @Override
    public LegalPerson find(Class<? extends LegalPerson> clazz, Integer id) {
        return ((LegalPersonService) new LegalPersonServiceLocator().getInstance(null)).read(id);
    }

    @Override
    public Class<LegalPerson> getDomainType() {
        return LegalPerson.class;
    }

    @Override
    public Integer getId(LegalPerson domainObject) {
        return domainObject.getLegalPersonId();
    }

    @Override
    public Class<Integer> getIdType() {
        return Integer.class;
    }

    @Override
    public Object getVersion(LegalPerson domainObject) {
        return domainObject.getLegalPersonId();
    }
}
